import fetch from 'common/src/utils/fetch'

const prefix = "/api/commonservice/commonparam";


/**
 * 获取值（通常由其他服务调用）
 */
export function getValue(code) {
    return fetch({
        url: prefix+`/value/${code}`,
        method: 'get',
    });
}

/**
 * 获取所有参数组
 */
export function getAllGroups() {
  return fetch({
    url: prefix+"/groups",
    method: 'get',
  });
}

/**
 * 添加group
 */
export function addGroup(groupvo) {
  return fetch({
    url: prefix+"/group",
    method: 'post',
    data: groupvo
  });
}

/**
 * 添加group
 */
export function updateGroup(groupCode, groupvo) {
  return fetch({
    url: prefix+`/group/${groupCode}`,
    method: 'put',
    data: groupvo
  });
}

/**
 * 删除group
 */
export function deleteGroup(groupCode) {
  return fetch({
    url: prefix+`/group/${groupCode}`,
    method: 'delete',
  });
}


/**
 * 获取参数
 */
export function getParam(code) {
  return fetch({
    url: prefix+`/param/${code}`,
    method: 'get',
  });
}


/**
 * 新增参数
 */
export function addParam(groupCode, paramVo) {
    return fetch({
        url: prefix+`/param/${groupCode}`,
        method: 'post',
        data: paramVo
    });
}

export function updateParam(code, paramVo) {
  return fetch({
    url: prefix+`/param/${code}`,
    method: 'put',
    data: paramVo
  });
}

export function deleteParam(code) {
  return fetch({
    url: prefix+"/param/"+code,
    method: 'delete',
  });
}

export function pageParam(pageNum,pageSize) {
  return fetch({
    url: prefix+`/param/page?pageNum=${pageNum}&pageSize=${pageSize}`,
    method: 'get',
  });
}
export function pageGroupParam(group,pageNum,pageSize) {
  return fetch({
    url: prefix+`/param/page/${group}?pageNum=${pageNum}&pageSize=${pageSize}`,
    method: 'get',
  });
}
